package thread;

public class Test01 {
    //线程优先级
    //Thread.MIN_PRIORITY; 值为1，含义：线程优先级最低
    //Thread.NORM_PRIORITY; 值为5，含义：线程优先级默认
    //Thread.MAX_PRIORITY; 值为10，含义：线程优先级最高

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                System.out.println("我是高优先我必须先行："+Thread.currentThread().getPriority());
            }

        });
        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                System.out.println("我是低优先我必须后："+Thread.currentThread().getPriority());
            }
        });
        Thread t3 = new Thread(() -> {
            for (int i = 0; i < 3; i++) {
                System.out.println("我是中优先我必须中间："+Thread.currentThread().getPriority());
            }
        });
        //设置线程优先级
        t1.setPriority(Thread.MAX_PRIORITY);
        t2.setPriority(Thread.MIN_PRIORITY);
        t3.setPriority(Thread.NORM_PRIORITY);

        //启动线程
        t1.start();
        t2.start();
        t3.start();

    }

}
